from xml.sax.saxutils import escape

class XmlSerializableException(Exception):

	_type = 'unknown'

	def __init__(self, message, type = None):

		super(XmlSerializableException, self).__init__(message)

		if(type):
			self._type = type

	def toXML(self):

		return '<error type="%s">%s</error>' % (self._type, escape(self.message))